<?	
	require_once 'config.php';
	error_reporting(E_ALL);
	ini_set("display_errors", 1);
	
	if(isset($_GET['id'])){
		$roomId = $_GET['id'];
	}
?>
<?php
	require_once 'php/Session.php';
	$session = new Session();

	if($session->isStarted()){

		require_once 'php/Room.php';
		$room = new Room($roomId);

?>
<html>
	<head>
		<meta charset="UTF-8" />
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

		<link rel="stylesheet" type="text/css" href="css/global.css">
		<link rel="stylesheet" type="text/css" href="css/room.css">

		<title>Debatepapo 2.0</title>
		<link rel="shortcut icon" href="image/favicon.ico" type="image/x-icon">

		<script src='js/tools.js'></script>
		<script src='js/main.js'></script>
		<script src='js/roomMain.js'></script>
		<script src='js/Group.js'></script>
		<script src='js/Room.js'></script>
		<script src='js/User.js'></script>
		<script src='js/Global.js'></script>
		<script src='js/Communicator.js'></script>
		<script src='js/Me.js'></script>
		<script src='js/Message.js'></script>
		<script src='js/Messenger.js'></script>
		<script src='js/ReplyTree.js'></script>
		<script src='js/Shortcut.js'></script>
		<script src='js/UserInformationBox.js'></script>

		<?php $room->placeData(); //$manager->placeRoomData($_GET['room']); ?>
		<?php echo '<script> globalCurrentTimezone='.$session->getData('timezone').';</script>';//include 'scroll.php'; ?>
	</head>
	<body onload='loadPage()'>

		<section id='shading' class='invisible' onclick='handleShading(event)'>
			<div class='sections'>
				<section id='replyTree' class='section invisible'>
					<button class='close' onclick='handleShading()'></button>
					<div class='wrapper'><div class='list'></div></div>
				</section>
			</div>
		</section>

		<section id='toolbar'>
			<div class='toolbarArea'>
				<div class='area'>
					<div class='menu'>
						<div class='button' onClick='leaveRoom()'><p>Sair da sala</p></div>
						<?php if($session->getData('isOwner_'.$roomId)) echo "<div class='button' onClick='closeRoom()'><p>Fechar sala</p></div>"; ?>
						<button class='leaveApp' onClick='logout();'><p>Deslogar</p></button>
					</div>
				</div>
			</div>
		</section>

		<section id='content'>
			
			<header class='top'></header>

			<div class='main'>
				<div class='left'></div>
				<div class='center'>
					
					<section id='messages'></section>
							
					<div class='bottom'>
						<textarea id='messageText' onKeyDown='return performKeyPressing(event)' onKeyUp='performKeyReleasing(event)' onkeypress='bindText()' oninput='bindText()' data-height='50' data-maxheight='160' style='height:50px; overflow: hidden'></textarea>
						<section id='composeMessageMenu'>
							<section id='reply' class='invisible'>
								<p>Resposta a</p>
								<p class='to'></p>
								<p class='message'></p>
								<div class='cancel button' onclick='stopReplying()'></div>
							</section>
							<div class='send button' onclick='global.getObject("me").sendMessage()'>Enviar</div>
						</section>
					</div>
				</div>
				<div class='right'>
					<section id='users'>
						<div class='online'></div>
						<div class='away'></div>
						<div class='offline'></div>
					</section>
				</div>
			</div>

		</section>

	</body>
</html>
<?php
	}else header('Location: index.php');
?>